/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using Microsoft.Scripting.Utils;

namespace Microsoft.Scripting.Actions {
    public static partial class DynamicSiteHelpers {

        #region Generated Maximum Site Target Arity

        // *** BEGIN GENERATED CODE ***
        // generated by function: gen_max_arity from: generate_dynsites.py

        internal const int MaximumArity = 10;

        // *** END GENERATED CODE ***

        #endregion

        public static Type MakeDynamicSiteType(params Type[] types) {
            return typeof(CallSite<>).MakeGenericType(new Type[] { MakeDynamicSiteTargetType(types) });
        }

        public static Type MakeDynamicSiteTargetType(Type/*!*/[] types) {
            ContractUtils.Requires(types != null && types.Length > 1, "types");

            switch (types.Length) {

                #region Generated Dynamic Site Target Type Maker

                // *** BEGIN GENERATED CODE ***
                // generated by function: gen_site_target_maker from: generate_dynsites.py

                case 2: return typeof(DynamicSiteTarget<,>).MakeGenericType(types);
                case 3: return typeof(DynamicSiteTarget<,,>).MakeGenericType(types);
                case 4: return typeof(DynamicSiteTarget<,,,>).MakeGenericType(types);
                case 5: return typeof(DynamicSiteTarget<,,,,>).MakeGenericType(types);
                case 6: return typeof(DynamicSiteTarget<,,,,,>).MakeGenericType(types);
                case 7: return typeof(DynamicSiteTarget<,,,,,,>).MakeGenericType(types);
                case 8: return typeof(DynamicSiteTarget<,,,,,,,>).MakeGenericType(types);
                case 9: return typeof(DynamicSiteTarget<,,,,,,,,>).MakeGenericType(types);
                case 10: return typeof(DynamicSiteTarget<,,,,,,,,,>).MakeGenericType(types);

                // *** END GENERATED CODE ***

                #endregion

                default:
                    return MakeBigSiteTargetType(types);
            }
        }
    }
}
